import React, {Component} from "react";
import {observer, inject} from "mobx-react";
import {withRouter} from "react-router-dom";
import {Icon, Tools, Toast} from "weaver-mobile";

const getLabel = Tools.getLabel;

@inject("statisticsStore")
@withRouter
@observer
export default class Statistic extends Component {
    toReport = (src) => {
        if (window.cpt_page_right["cpt_rpt_Display"] === true) {
            this.props.history.push(src)
        } else {
            Toast.fail(window.cpt_page_right["msg"], 2)
        }
    };

    renderContent(list) {
        return (
            list.map((item, index) => (
                <div key={index} className='chart-list-item'>
                    <div className='chart-list-item-link' onClick={() => this.toReport(item.src)}>
                        <div className='chart-list-item-content'>
                            <div>{item.title}</div>
                            <Icon className='chart-list-item-icon' type='right'/>
                        </div>
                    </div>
                </div>
            ))
        )
    }

    render() {
        let options = [
            {
                title: getLabel(16597, "资产组报表"),
                src: "/report/group"
            }, {
                title: getLabel(1508, "使用人"),
                src: "/report/resource"
            }, {
                title: getLabel(21030, "使用部门"),
                src: "/report/dept"
            }, {
                title: getLabel(830, "资产状态"),
                src: "/report/state"
            }
        ];
        return (
            <div className='chart-list'>
                {
                    this.renderContent(options)
                }
            </div>)
    }
}
